<?php

/**
 * This is the model class for table "PAYMENT".
 *
 * The followings are the available columns in table 'PAYMENT':
 * @property integer $PAYMENT_ID
 * @property integer $INVOICE_NO
 * @property integer $PAYMENT_AMOUNT
 * @property string $PAYMENT_DATE
 * @property integer $PAYMENT_TYPE
 * @property integer $CHECK_NO
 * @property string $RECEIPTER
 * @property string $DESCRIPTION
 * @property string $PAYER_ID
 * @property integer $PAYER_ID_TYPE
 * @property integer $MERCHANT_TRANSACTION_ID
 *
 * The followings are the available model relations:
 * @property MERCHANTTRANSACTIONLOG $mERCHANTTRANSACTION
 * @property NOTIFICATION[] $nOTIFICATIONs
 */
class PAYMENT extends Post3ActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return PAYMENT the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'POST3.PAYMENT';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('PAYMENT_AMOUNT, PAYMENT_DATE', 'required'),
			array('INVOICE_NO, PAYMENT_AMOUNT, PAYMENT_TYPE, CHECK_NO, PAYER_ID_TYPE, MERCHANT_TRANSACTION_ID', 'numerical', 'integerOnly'=>true),
			array('RECEIPTER', 'length', 'max'=>64),
			array('DESCRIPTION', 'length', 'max'=>255),
			array('PAYER_ID', 'length', 'max'=>24),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('PAYMENT_ID, INVOICE_NO, PAYMENT_AMOUNT, PAYMENT_DATE, PAYMENT_TYPE, CHECK_NO, RECEIPTER, DESCRIPTION, PAYER_ID, PAYER_ID_TYPE, MERCHANT_TRANSACTION_ID', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'mERCHANTTRANSACTION' => array(self::BELONGS_TO, 'MERCHANTTRANSACTIONLOG', 'MERCHANT_TRANSACTION_ID'),
			'nOTIFICATIONs' => array(self::HAS_MANY, 'NOTIFICATION', 'PAYMENT_ID'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'PAYMENT_ID' => 'Payment',
			'INVOICE_NO' => 'Invoice No',
			'PAYMENT_AMOUNT' => 'Payment Amount',
			'PAYMENT_DATE' => 'Payment Date',
			'PAYMENT_TYPE' => 'Payment Type',
			'CHECK_NO' => 'Check No',
			'RECEIPTER' => 'Receipter',
			'DESCRIPTION' => 'Description',
			'PAYER_ID' => 'Payer',
			'PAYER_ID_TYPE' => 'Payer Id Type',
			'MERCHANT_TRANSACTION_ID' => 'Merchant Transaction',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('PAYMENT_ID',$this->PAYMENT_ID);
		$criteria->compare('INVOICE_NO',$this->INVOICE_NO);
		$criteria->compare('PAYMENT_AMOUNT',$this->PAYMENT_AMOUNT);
		$criteria->compare('PAYMENT_DATE',$this->PAYMENT_DATE,true);
		$criteria->compare('PAYMENT_TYPE',$this->PAYMENT_TYPE);
		$criteria->compare('CHECK_NO',$this->CHECK_NO);
		$criteria->compare('RECEIPTER',$this->RECEIPTER,true);
		$criteria->compare('DESCRIPTION',$this->DESCRIPTION,true);
		$criteria->compare('PAYER_ID',$this->PAYER_ID,true);
		$criteria->compare('PAYER_ID_TYPE',$this->PAYER_ID_TYPE);
		$criteria->compare('MERCHANT_TRANSACTION_ID',$this->MERCHANT_TRANSACTION_ID);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}